/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.me.hello;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.net.URL;

/**
 *
 * @author Matias
 */
public class Crucero {
    
    private static String RUTA_IMAGEN= "images/crucero_";
    private static String RUTA_IMAGEN_EXPLOSION = "images/explosion_barco.png";

    private int posX;
    private int posY;
    private java.awt.Image imagen;
    URL urlImagen;
    private java.awt.Image imagenExplosion;
    private String orientacion;
    private boolean seHundioBarco;
    
    public Crucero() {

    }

    public Crucero(int posX, int posY,String orientacion) {
        this.posX = posX;
        this.posY = posY;
        
        urlImagen = getClass().getClassLoader().getResource(RUTA_IMAGEN + orientacion + ".png");
        imagen = java.awt.Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(urlImagen);
        URL urlImagenExplosion = getClass().getClassLoader().getResource(RUTA_IMAGEN_EXPLOSION);
        imagenExplosion = java.awt.Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(urlImagenExplosion);
        
        this.orientacion = orientacion;
    }
    
    public String GetOrientacion()
    {
        return this.orientacion;
    }
    public void SetOrientacion(String ori)
    {
        this.orientacion = ori;
    }
    
    public int getPosX() {
        return posX;
    }

    public void setPosX(int posX) {
        this.posX = posX;
    }

    public int getPosY() {
        return posY;
    }

    public void setPosY(int posY) {
        this.posY = posY;
    }

    public boolean isSeHundioBarco() {
        return seHundioBarco;
    }

    public void setSeHundioBarco(boolean seHundioBarco) {
        this.seHundioBarco = seHundioBarco;
    }

    public void display(Graphics g)
    {    
        
        if(!this.seHundioBarco)
        {
            g.drawImage(this.imagen, this.posX, this.posY, null);
        } else 
        {
            g.drawImage(this.imagenExplosion, this.posX, this.posY, null);
        }
    }
    
    public void moverBarco(int x, int y) {
        urlImagen = getClass().getClassLoader().getResource(RUTA_IMAGEN + orientacion + ".png");
        imagen = java.awt.Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(urlImagen);
        //Mueve el barco
        this.setPosX(x);
        this.setPosY(y);
    }
    
    
}
